<?php
namespace YunCangChu\Controller;
use Think\Controller;
use think\Cookie;

class OrderController extends PublicController {
    public function index1()
    {

        $url = C('api_url')['获取全部订单'];
        $data['FuncName']  = 'GET_ORDER_LIST';
        $data['LoginID']   = $this->LoginID;
        $data['PageIndex'] = 1;
        $app_data          = baseMD5($data);
        $return_arr        = cUrl($url,$header=null, $app_data);
        //dump($return_arr);die;
        $this->assign('data',$return_arr['ReturnData']['rows']);
        $this->display('index');
    }
    //全部订单分页处理
    public function allOrder()
    {
        $page = I('page',1);
        $url = C('api_url')['获取全部订单'];
        $data['FuncName']  = 'GET_ORDER_LIST';
        $data['LoginID']   = $this->LoginID;
        $data['PageIndex'] = $page;
        $app_data          = baseMD5($data);
        $return_arr        = cUrl($url,$header=null, $app_data);
        //dump($return_arr);die;
        $this->assign('data',$return_arr['ReturnData']['rows']);
        $html = $this->fetch("allOrder");
        echo $html;
    }

    //获取待支付订单
    public function paidOrder()
    {
        $page = I('page',1);
        $url = C('api_url')['获取待支付订单'];
        $data['FuncName']  = 'GET_ORDER_TOPAID_LIST';
        $data['LoginID']   = $this->LoginID;
        $data['PageIndex'] = $page;
        $app_data          = baseMD5($data);
        $return_arr        = cUrl($url,$header=null, $app_data);
        $this->assign('data',$return_arr['ReturnData']['rows']);
        $html = $this->fetch("paidOrder");
        echo $html;
    }
    //获取待评价订单
    public function evaluatedOrder()
    {
        $page = I('page',1);
        $url = C('api_url')['待评价订单'];
        $data['FuncName']  = 'GET_ORDER_TOCOMM_LIST';
        $data['LoginID']   = $this->LoginID;
        $data['PageIndex'] = $page;
        $app_data          = baseMD5($data);
        $return_arr        = cUrl($url,$header=null, $app_data);
        $this->assign('data',$return_arr['ReturnData']['rows']);
        $html = $this->fetch("evaluatedOrder");
        echo $html;
    }
    //取消订单
    public function cancelOrder()
    {
        $order = I('order','');
        $url = C('api_url')['取消订单'];
        $data['FuncName']  = 'ORDER_CANCEL';
        $data['LoginID']  = $this->LoginID;
        $data['OrderSN']  = $order;
        $app_data          = baseMD5($data);
        $return_arr        = cUrl($url,$header=null, $app_data);
        if($return_arr['ReturnCode'] == 0)
        {
            echo  0;
        }
        else
        {
            echo $return_arr['ReturnText'];
        }
    }

    //订单评价
    public function evaluateOrder()
    {
        if(IS_GET)
        {
            $this->display();
        }
        else
        {

            $data = I('post.');
            $url = C('api_url')['待评价订单'];
            $data['FuncName']  = 'ORDER_COMM';
            $data['LoginID']   = $this->LoginID;
            $app_data          = baseMD5($data);
            $return_arr        = cUrl($url,$header=null, $app_data);
            $this->ajaxReturn($return_arr);
        }
    }

}